#include "LogFormat.h"
#include "TimeInfo.h"
#include <iostream>
#include <sstream>
#include <thread>

std::string LogFormat::format(const std::string& level, const std::string& log, const std::string& file, int line)
{
	std::stringstream ss;
	ss << "[" << mTimeInfo->GetTimeNow()
		<< "][" << level << "]["
		<< file << ":" << line << "]["
		<< std::this_thread::get_id()
		<< "]:" << log;
	return ss.str();
}

LogFormat::LogFormat():mTimeInfo(new TimeInfo)
{

}

LogFormat::~LogFormat()
{
	if (mTimeInfo)
	{
		delete mTimeInfo;
		mTimeInfo = nullptr;
	}
}
